﻿@using si.caha.Repository;

@{
    Layout = "/tpl/_layout.cshtml";
    PageData["PageTitle"] = "Delete image?";

    var id = UrlData[0].IsInt() ? UrlData[0].AsInt() : 0;

    var dataContext = new DataContext();
    var imageRepository = new ImageRepository(dataContext);
    var image = imageRepository.Get(id);

    if (IsPost)
    {
        imageRepository.Delete(id);
        
        if (Request["ReturnUrl"] != null)
        {
            Response.Redirect("~" + Request["ReturnUrl"]);
        }
        Response.Redirect("~/Admin");
    }
}
<img src="@Href(@image.Path)" height="100px" width="100px" />
<form method="post" action="">
    <input type="submit" value="Confirm" />
</form>